﻿Imports NewHeaderSystems.Archive.Data

Public Class SystemSettings

    Private Shared _instance As SystemSettings
    Public Shared ReadOnly Property Instance() As SystemSettings
        Get
            If _instance Is Nothing Then
                _instance = New SystemSettings
                _instance.Load()
            End If

            Return _instance
        End Get
    End Property

    Private Sub Load()
        Dim settings As SysSetting = DataScript.GetSystemSettings()
        With settings
            AplConfirmFileName = .APLConfirmFileName
            TSConfirmFileName = .TSConfirmFileName
            AdventConfirmFileName = .AdventConfirmFileName
            MatchFileName = .MatchFileName
            DataFilePath = .DataFilePath
            AccountID = .DefaultAccountID
            FtpServer = .FTPServer
            FtpUsername = .FTPUserId
            FtpPassword = .FTPPassWord
            FtpChangeDirectory = .FTPChangeDir
        End With
    End Sub

    Public Sub Save()
        Dim settings As SysSetting = DataScript.GetSystemSettings()
        With settings
            .APLConfirmFileName = AplConfirmFileName
            .TSConfirmFileName = TSConfirmFileName
            .AdventConfirmFileName = AdventConfirmFileName
            .MatchFileName = MatchFileName
            .DataFilePath = DataFilePath
            .DefaultAccountID = AccountID
            .FTPServer = FtpServer
            .FTPUserId = FtpUsername
            .FTPPassWord = FtpPassword
            .FTPChangeDir = FtpChangeDirectory
        End With
        DataScript.SaveSystemSettings(settings)
    End Sub

    Private _ftpServer As String
    Public Property FtpServer() As String
        Get
            Return _ftpServer
        End Get
        Set(ByVal value As String)
            _ftpServer = value
        End Set
    End Property


    Private _ftpUsername As String
    Public Property FtpUsername() As String
        Get
            Return _ftpUserName
        End Get
        Set(ByVal value As String)
            _ftpUserName = value
        End Set
    End Property


    Private _ftpPassword As String
    Public Property FtpPassword() As String
        Get
            Return _ftpPassword
        End Get
        Set(ByVal value As String)
            _ftpPassword = value
        End Set
    End Property


    Private _ftpChangeDirectory As String
    Public Property FtpChangeDirectory() As String
        Get
            Return _ftpChangeDirectory
        End Get
        Set(ByVal value As String)
            _ftpChangeDirectory = value
        End Set
    End Property


    Private _accountID As String
    Public Property AccountID() As String
        Get
            Return _accountID
        End Get
        Set(ByVal value As String)
            _accountID = value
        End Set
    End Property

    Private _aplConfirmFileName As String
    Public Property AplConfirmFileName() As String
        Get
            Return _aplConfirmFileName
        End Get
        Set(ByVal value As String)
            _aplConfirmFileName = value
        End Set
    End Property


    Private _tsConfirmFileName As String
    Public Property TSConfirmFileName() As String
        Get
            Return _tsConfirmFileName
        End Get
        Set(ByVal value As String)
            _tsConfirmFileName = value
        End Set
    End Property

    Private _adventConfirmFileName As String
    Public Property AdventConfirmFileName() As String
        Get
            Return _adventConfirmFileName
        End Get
        Set(ByVal value As String)
            _adventConfirmFileName = value
        End Set
    End Property

    Private _matchFileName As String
    Public Property MatchFileName() As String
        Get
            Return _matchFileName
        End Get
        Set(ByVal value As String)
            _matchFileName = value
        End Set
    End Property


    Private _dataFilePath As String
    Public Property DataFilePath() As String
        Get
            Return _dataFilePath
        End Get
        Set(ByVal value As String)
            _dataFilePath = value
        End Set
    End Property

    Public ReadOnly Property IsAplEnabled() As Boolean
        Get
            Return Not String.IsNullOrEmpty(_instance.AplConfirmFileName)
        End Get
    End Property

End Class
